package com.yanqu.road.server.channelserver.cmd.activity.tonbing;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ChannelTonBingProto;
import com.yanqu.road.server.channelserver.manager.activity.tonbing.ChannelTonBingMgr;
import com.yanqu.road.server.channelserver.manager.activity.tonbing.activity.ChannelTonBingActivity;
import com.yanqu.road.server.cmd.CrossChannelCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.protocol.ChannelProtocol;

@Cmd(code = ChannelProtocol.N_TON_BING_UPDATE_HORSE, desc = "")
public class ChannelTonBingChangeHorseCmd extends CrossChannelCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ChannelTonBingProto.ChannelTonBingChangeHorseReqMsg reqMsg = ChannelTonBingProto.ChannelTonBingChangeHorseReqMsg.parseFrom(packet.getBytes());
        ChannelTonBingActivity activity = ChannelTonBingMgr.getActivity(reqMsg.getActivityId());
        try {
            activity.changeHorse(packet.getPlayerId(), reqMsg.getHorse());
        } catch (Exception e) {
            e.printStackTrace();
            log.error("ton bing add horse fail! activityId {} userId {} horseId {}.", reqMsg.getActivityId(), packet.getPlayerId(), reqMsg.getHorse());
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
